-
Notifications
You must be signed in to change notification settings - Fork 7
feat: use grpc secure channel #783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #783 +/- ##
==========================================
- Coverage 88.99% 87.03% -1.97%
==========================================
Files 39 40 +1
Lines 5653 5760 +107
==========================================
- Hits 5031 5013 -18
- Misses 622 747 +125 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| err, stderr_file = tempfile.mkstemp(suffix="speos_err.txt", dir=logfile_loc) | ||
|
|
||
| subprocess.Popen(command, stdout=out, stderr=err) # nosec B603 | ||
| return Speos( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will not create local RPC server if using version before 2025.2.3. We can:
Option 1. if version <= 252, using the previous Speos method and raise security warning message
Option 2. raise error directly that this method only supports from 252.
@etiennearnal @StefanThoene @jomadec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pluAtAnsys we did Service Packs for all previous releases of SpeosRPC_Server (251 & 252), so the goal is to no more support the previous versions that has the vulnerabilities.
I think we have to move forward and consider that users have to use the latest available Service Pack (supporting --transport_xxx option). In other cases, user can duplicate the function manually on there side.
| assert running is not closed | ||
|
|
||
|
|
||
| @patch.object(subprocess, "Popen") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@StefanThoene let's check on this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pluAtAnsys The test doesn't make any sense, client cannot start a docker from python. Docker image must be started by user before launching the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| from ansys.speos.core import Speos | ||
| speos = Speos(host="127.0.0.1", port=50098) | ||
| speos = Speos(channel = default_docker_channel()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| speos = Speos(channel = default_docker_channel()) | |
| speos = Speos() | |
| Be aware that such docker is launched via insecure channel | |
| By default, the ``Speos`` instance connects to ``"localhost"`` on | |
| port ``50098``. | |
| You can change this by modifying the ``host`` and ``port`` | |
| parameters of ``default_docker_channel``, but note that you must also modify | |
| your ``docker run`` command by changing the ``<HOST-PORT>-50098`` argument. | |
| The following tabs show the commands that set the ``host`` and ``port`` | |
| parameters of ``default_docker_channel``. | |
| .. code:: python | |
| from ansys.speos.core import Speos, default_docker_channel | |
| speos = Speos(channel = default_docker_channel(host="127.0.0.1", port=50098)) |
@etiennearnal @jomadec could you please review this? also, could we provide explanation/an example to launch docker in secure way?
| elif [[ "$speos_version" == "dev" ]]; then | ||
| docker run --detach --name speos-rpc -p 127.0.0.1:50098:50098 -e SPEOS_LOG_LEVEL=2 -e ANSYSLMD_LICENSE_FILE=${{ env.ANSYSLMD_LICENSE_FILE }} -v "${{ github.workspace }}/tests/assets:/app/assets" --entrypoint /app/SpeosRPC_Server.x ghcr.io/ansys/speos-rpc:$speos_version -m 25000000 --host 0.0.0.0 | ||
| elif [[ "$speos_version" == "2025.2.4.35476" ]]; then | ||
| docker run --detach --name speos-rpc -p 127.0.0.1:50098:50098 -e SPEOS_LOG_LEVEL=2 -e ANSYSLMD_LICENSE_FILE=${{ env.ANSYSLMD_LICENSE_FILE }} -v "${{ github.workspace }}/tests/assets:/app/assets" --entrypoint /app/SpeosRPC_Server.x ghcr.io/ansys/speos-rpc:$speos_version -m 25000000 --transport_insecure--host 0.0.0.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| docker run --detach --name speos-rpc -p 127.0.0.1:50098:50098 -e SPEOS_LOG_LEVEL=2 -e ANSYSLMD_LICENSE_FILE=${{ env.ANSYSLMD_LICENSE_FILE }} -v "${{ github.workspace }}/tests/assets:/app/assets" --entrypoint /app/SpeosRPC_Server.x ghcr.io/ansys/speos-rpc:$speos_version -m 25000000 --transport_insecure--host 0.0.0.0 | |
| docker run --detach --name speos-rpc -p 127.0.0.1:50098:50098 -e SPEOS_LOG_LEVEL=2 -e ANSYSLMD_LICENSE_FILE=${{ env.ANSYSLMD_LICENSE_FILE }} -v "${{ github.workspace }}/tests/assets:/app/assets" --entrypoint /app/SpeosRPC_Server.x ghcr.io/ansys/speos-rpc:$speos_version -m 25000000 --transport_insecure --host 0.0.0.0 |
| export LICENSE_SERVER="[email protected]" | ||
| docker run --detach --name speos-rpc -p 127.0.0.1:50098:50098 -e ANSYSLMD_LICENSE_FILE=$LICENSE_SERVER --entrypoint /app/SpeosRPC_Server.x ghcr.io/ansys/speos-rpc:251 | ||
| docker run --detach --name speos-rpc -p 127.0.0.1:50098:50098 -e ANSYSLMD_LICENSE_FILE=$LICENSE_SERVER --entrypoint /app/SpeosRPC_Server.x ghcr.io/ansys/speos-rpc:252 --transport_insecure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| docker run --detach --name speos-rpc -p 127.0.0.1:50098:50098 -e ANSYSLMD_LICENSE_FILE=$LICENSE_SERVER --entrypoint /app/SpeosRPC_Server.x ghcr.io/ansys/speos-rpc:252 --transport_insecure | |
| docker run --detach --name speos-rpc -p 127.0.0.1:50098:50098 -e ANSYSLMD_LICENSE_FILE=$LICENSE_SERVER --entrypoint /app/SpeosRPC_Server.x ghcr.io/ansys/speos-rpc:252 --transport_insecure --host 0.0.0.0 |
| $env:LICENSE_SERVER="[email protected]" | ||
| docker run --detach --name speos-rpc -p 127.0.0.1:50098:50098 -e ANSYSLMD_LICENSE_FILE=$env:LICENSE_SERVER --entrypoint /app/SpeosRPC_Server.x ghcr.io/ansys/speos-rpc:251 | ||
| docker run --detach --name speos-rpc -p 127.0.0.1:50098:50098 -e ANSYSLMD_LICENSE_FILE=$env:LICENSE_SERVER --entrypoint /app/SpeosRPC_Server.x ghcr.io/ansys/speos-rpc:252 --transport_insecure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| docker run --detach --name speos-rpc -p 127.0.0.1:50098:50098 -e ANSYSLMD_LICENSE_FILE=$env:LICENSE_SERVER --entrypoint /app/SpeosRPC_Server.x ghcr.io/ansys/speos-rpc:252 --transport_insecure | |
| docker run --detach --name speos-rpc -p 127.0.0.1:50098:50098 -e ANSYSLMD_LICENSE_FILE=$env:LICENSE_SERVER --entrypoint /app/SpeosRPC_Server.x ghcr.io/ansys/speos-rpc:252 --transport_insecure --host 0.0.0.0 |
| set LICENSE_SERVER="[email protected]" | ||
| docker run --detach --name speos-rpc -p 127.0.0.1:50098:50098 -e ANSYSLMD_LICENSE_FILE=%LICENSE_SERVER% --entrypoint /app/SpeosRPC_Server.x ghcr.io/ansys/speos-rpc:251 | ||
| docker run --detach --name speos-rpc -p 127.0.0.1:50098:50098 -e ANSYSLMD_LICENSE_FILE=%LICENSE_SERVER% --entrypoint /app/SpeosRPC_Server.x ghcr.io/ansys/speos-rpc:252 --transport_insecure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| docker run --detach --name speos-rpc -p 127.0.0.1:50098:50098 -e ANSYSLMD_LICENSE_FILE=%LICENSE_SERVER% --entrypoint /app/SpeosRPC_Server.x ghcr.io/ansys/speos-rpc:252 --transport_insecure | |
| docker run --detach --name speos-rpc -p 127.0.0.1:50098:50098 -e ANSYSLMD_LICENSE_FILE=%LICENSE_SERVER% --entrypoint /app/SpeosRPC_Server.x ghcr.io/ansys/speos-rpc:252 --transport_insecure --host 0.0.0.0 |
| cat GH_TOKEN.txt | docker login ghcr.io -u "$GH_USERNAME" --password-stdin | ||
| docker pull ghcr.io/ansys/speos-rpc:251 | ||
| docker run --detach --name speos-rpc -p 127.0.0.1:50098:50098 -e ANSYSLMD_LICENSE_FILE=$LICENSE_SERVER --entrypoint /app/SpeosRPC_Server.x ghcr.io/ansys/speos-rpc:251 | ||
| docker run --detach --name speos-rpc -p 127.0.0.1:50098:50098 -e ANSYSLMD_LICENSE_FILE=$LICENSE_SERVER --entrypoint /app/SpeosRPC_Server.x ghcr.io/ansys/speos-rpc:251 --transport_insecure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| docker run --detach --name speos-rpc -p 127.0.0.1:50098:50098 -e ANSYSLMD_LICENSE_FILE=$LICENSE_SERVER --entrypoint /app/SpeosRPC_Server.x ghcr.io/ansys/speos-rpc:251 --transport_insecure | |
| docker run --detach --name speos-rpc -p 127.0.0.1:50098:50098 -e ANSYSLMD_LICENSE_FILE=$LICENSE_SERVER --entrypoint /app/SpeosRPC_Server.x ghcr.io/ansys/speos-rpc:252 --transport_insecure --host 0.0.0.0 |
| return False | ||
| try: | ||
| grpc.channel_ready_future(self.channel).result(timeout=60) | ||
| grpc.channel_ready_future(self.channel).result(timeout=10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was the default timeout changed on purpose?

Description
Including the usage of secure channels upon Speos client.
Secure channel creation is based on cyberchannel.
[breaking change]
Speosconstructor parametershostandportare removed. Please consider to create thegrpc.Channelusingdefault_local_channel:Checklist
feat: add optical property)